const userSearch = defineStore('userSearch', {
  state: () => ({
    searchArraylist: [],
    schoolArrayList: [], // 学校
    majorArrayList: [], // 专业
    jobArrayList: [], // 职业
    advancedList: [], // 高级
  }),
  actions: {
    saveSearchInfoChange() {
      // 添加方法
      this.searchArraylist = [
        ...this.schoolArrayList,
        ...this.majorArrayList,
        ...this.jobArrayList,
        ...this.advancedList,
      ];
    },
    saveSchoolInfoChange(dataInfo) {
      // 添加方法
      this.schoolArrayList = dataInfo;
      this.saveSearchInfoChange();
    },
    saveMajorInfoChange(dataInfo) {
      this.majorArrayList = dataInfo;
      this.saveSearchInfoChange();
    },
    saveJobInfoChange(dataInfo) {
      this.jobArrayList = dataInfo;
      this.saveSearchInfoChange();
    },
    saveAdvancedInfoChange(dataInfo) {
      this.advancedList = dataInfo;
      this.saveSearchInfoChange();
    },

    delSearchInfoChange(idx, val) {
      // 删除查询条件
      this.searchArraylist.splice(idx, 1);
    },

    delAllSearchInfo() {
      this.searchArraylist = [];
      this.schoolArrayList = [];
      this.majorArrayList = [];
      this.jobArrayList = [];
      this.advancedList = [];
    },
  },
});

export default userSearch;
